package com.project.system.Controller;


import com.project.system.Service.UserService;
import com.project.system.beans.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping("/addUser")
    public Object adduser(@RequestParam(value = "name")String name,
                          @RequestParam(value = "password")String password){
        Map<String,Object> map =new HashMap<>();
        User user = new User();
        user.setName(name);
        user.setPassword(password);


        int check =userService.addUser(user);
        if(check==1){
            map.put("code",200);
            map.put("msg", "success!");
        }else{
            map.put("code",100);
            map.put("msg", "fail!");
        }

        return map;
    }

}
